package de.mahosoftware.gwt.games.durak.client.module;


public class Card implements Comparable<Card> {

	private Color color = null;
	private int value = -1;
	private CardColor cardColor = null;
	private String ressource;

	public Card(int value, Color color, CardColor cardColor) {
		setColor(color);
		setCardColor(cardColor);
		setValue(value);
		setRessource();
	}

	public Card(int value, Color color) {
		setColor(color);
		setValue(value);
		setRessource();
		System.out.println("Color " + color.name() + " " + color.ordinal());
	}

	public enum Color {
		Karo, Herz, Pik, Kreuz
	}

	public enum CardColor {
		blue, red
	}

	public Color getColor() {
		return color;
	}

	private void setColor(Color color) {
		this.color = color;
	}

	public int getValue() {
		return value;
	}

	private void setValue(int value) {
		this.value = value;
	}

	public CardColor getCardColor() {
		return cardColor;
	}

	private void setCardColor(CardColor cardColor) {
		this.cardColor = cardColor;
	}

	public String getRessource() {
		return ressource;
	}

	private void setRessource() {
		if (value < 10) {
			ressource = "images/card/" + color.name() + "0" + value + ".png";
		} else {
			ressource = "images/card/" + color.name() + value + ".png";
		}
	}

	public Card printInfo() {
		System.out.println(getValue() + "\t|" + getColor().name() + "\t|"
				+ getRessource());
		return this;
	}

	@Override
	public int compareTo(Card o2) {
		if (color.ordinal() < o2.getColor().ordinal())
			return -1;
		else if (color.ordinal() > o2.getColor().ordinal())
			return 1;
		if (getValue() < o2.getValue()) {
			return -1;
		} else if (getValue() > o2.getValue()) {
			return 1;
		} else
			return 0;
	}

}
